package util;

import java.util.regex.*;

import ex.UnparsableToDoubleException;
import ex.UnparsableToIntegerException;

public class RegexUtil {
	public static boolean isParsableToInt(String input){
		return input.matches("^\\d+$");
	}
	public static boolean isValidEmail(String email){
		String expression = "^[\\w\\-]([\\.\\w])+[\\w]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";
        CharSequence inputStr = email;
        Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(inputStr);

        return matcher.matches();
	}
	public static boolean isParsableToDouble(String input) {
		return input.matches("^\\d+\\.?\\d*$");
	}
	public static boolean isNullOrEmpty(String input)	{
		if(input!=null){
			return input.length()==0 || input.matches("^\\s+$");
		}
		else{
			return true;
		}
	}
	
	public static String[] splitDiyez(String input){
		String[] pieces= input.split("#");
		return pieces;
	}
}
